home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2005 June (DVD) / DPPRO0605DVD.iso / Install / program files / Borland / BDS / 3.0 / Demos / Delphi.Net / CLR / Remoting / uInstService.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  2004-10-22  |  2.4 KB  |  81 lines

  1. unit uInstService;
  2. //------------------------------------------------------------------------------
  3. //  Last updated:   11/06/03
  4. //  Author:         Dennis Passmore
  5. //  Company:        Ultimate Software, Inc.
  6. //  Contact info:   dennis_passmore@ultimatesoftware.com
  7. //
  8. //  Compatibility:  Delphi for .NET HTTP service demo
  9. //
  10. //  Description:    TNTKeyService class implements base .NET service class.
  11. //                  TLockserver class implements base ILockserver which is
  12. //                  exported via .NET Remoting
  13. //
  14. //------------------------------------------------------------------------------
  15. interface
  16.  
  17. uses
  18.   System.ServiceProcess,
  19.   System.Configuration.Install,
  20.   System.ComponentModel, // for RunInstaller
  21.   System.Collections,    // for IDictionary
  22.   Microsoft.Win32;       // for RegistryKey
  23.  
  24. const
  25.   cNTServiceDesc = 'Delphi for .NET HTTP Service Demo';
  26.   cNTServiceDisp = 'Delphi HTTP Service';
  27.   cNTServiceProg = 'D4DN_NT_HTTPService';
  28.  
  29. type
  30.   [RunInstaller(True)]
  31.   TNTServiceInstaller = class(System.Configuration.Install.Installer)
  32.   private
  33.     fDepends: array of string;
  34.     fProcessInstaller: System.ServiceProcess.ServiceProcessInstaller;
  35.     fInstaller: System.ServiceProcess.ServiceInstaller;
  36.   strict protected
  37.     procedure OnAfterInstall(savedState: IDictionary); override;
  38.   public
  39.     constructor Create;
  40.   end;
  41.  
  42. var
  43.   NTServiceInstaller: TNTServiceInstaller = nil;
  44.  
  45. implementation
  46.  
  47. constructor TNTServiceInstaller.Create;
  48. begin
  49.   inherited Create;
  50.  
  51.   SetLength(fDepends, 1);
  52.   fDepends[0] := 'Event Log';
  53.  
  54.   fProcessInstaller := System.ServiceProcess.ServiceProcessInstaller.Create;
  55.   fProcessInstaller.Account := System.ServiceProcess.ServiceAccount.LocalSystem;
  56.  
  57.   fInstaller := System.ServiceProcess.ServiceInstaller.Create;
  58.   fInstaller.ServiceName := cNTServiceProg;
  59.   fInstaller.DisplayName := cNTServiceDisp;
  60.   fInstaller.StartType := System.ServiceProcess.ServiceStartMode.Manual;
  61.   fInstaller.ServicesDependedOn := fDepends;
  62.  
  63.   Installers.Add(fInstaller);
  64.   Installers.Add(fProcessInstaller);
  65. end;
  66.  
  67. procedure TNTServiceInstaller.OnAfterInstall(savedState: IDictionary);
  68. var
  69.   ServiceKey: RegistryKey;
  70. begin
  71.   ServiceKey := Microsoft.Win32.Registry.LocalMachine.OpenSubKey(
  72.     'SYSTEM\CurrentControlSet\Services\' + cNTServiceProg, True);
  73.   if (ServiceKey <> nil) then
  74.   begin
  75.     ServiceKey.SetValue('Description', cNTServiceDesc );
  76.     ServiceKey.Close;
  77.   end;
  78. end;
  79.  
  80. end.
  81.